﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RabbitMQ_Test2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private double time = 0;
        private async void button1_Click(object sender, EventArgs e)
        {
            bool? value1 = false;
            string value2 = null;

            //StringBuilder Text = new StringBuilder();
            //for (int j = 0; j < 10;j++ )
            //{
            //    using (var rmqu1 = new RabbitMQUtility("synchronization_table"+j, "ycgwl_crm", "172.16.251.187", 5673, "test", "123abc", "rabbitmq1.rabbit.com", "test2"))
            //    {

            //        for (int i = 0; i < 6; i++)
            //        {

            //            value1 = await rmqu1.Producer("测试" + DateTime.Now.ToString() + System.Guid.NewGuid().ToString());
            //        }
            //    }
            //}
            //    return;
            ////    //rmqu1 = new RabbitMQUtility("synchronization_table2", "ycgwl_crm", "172.16.251.187", 5673, "ycgwlrmq", "123abc~~~", "rabbitmq1.rabbit.com", "ycgwl_crm_vhost");
            ////    for (int i = 0; i < 10 * 1; i++)
            ////    {

            ////        value1 = await rmqu1.Producer("测试" + DateTime.Now.ToString());
            ////    }
            //}
            //for (int i = 0; i < 10; i++)
            //{
            using (var rmqu = new RabbitMQUtility("synchronization_table1", "ycgwl_crm", "172.16.251.187", 5673, "admin", "123abc", "rabbitmq1.rabbit.com", "test"))
            {
                List<bool?> values = new List<bool?>();

                for (int i = 0; i < 99; i++)
                {
                    values.Add(await rmqu.Producer(Guid.NewGuid().ToString()));
                }
                List<string> sss = await rmqu.Consumer(100);
                int x = sss.Count();
                foreach (var item in sss)
                {
                    this.textBox1.Text += (item + System.Environment.NewLine);
                }
                List<int> s1 = new List<int>();
                List<int> s2 = new List<int>();
                List<int> s3 = new List<int>();
                //s1.Where(a => (a > 0 ? s2.Add(a),false : s3.Add(a),false));
                //for (int j = 0; j < 100; j++)
                //{

                //    DateTime t1 = DateTime.Now;

                //    //value1 = await rmqu.Producer("测试" + DateTime.Now.ToString());
                //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                //    value2 = await rmqu.Consumer();
                //    Text.Insert(0, System.Environment.NewLine);
                //    Text.Insert(0, j);
                //    Text.Insert(0, "_");
                //    Text.Insert(0, i);
                //    Text.Insert(0, "_");
                //    Text.Insert(0, value2);
                //    this.textBox1.Text = Text.ToString();
                //    DateTime t2 = DateTime.Now;
                //    TimeSpan t = t2 - t1;
                //    time += t.TotalMilliseconds;
                //    this.label1.Text = time.ToString();
                //    await Task.Delay(0);
                //}
                //}
                //await Task.Delay(100);

            }
            //this.textBox1.Text = Text.ToString();
            //this.label1.Text = time + "";



        }

    }
}
